package com.zzq.service.impl;

import com.zzq.domain.dto.SmilePointRuleDTO;
import com.zzq.domain.entity.SmilePointRule;
import com.zzq.domain.search.PointRuleSearchParamet;
import com.zzq.mapper.SmilePointRuleMapper;
import com.zzq.service.SmilePointRuleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzq.util.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 小布
 * @since 2023-10-24
 */
@Service
public class SmilePointRuleServiceImpl extends ServiceImpl<SmilePointRuleMapper, SmilePointRule> implements SmilePointRuleService {

    @Autowired
    SmilePointRuleMapper pointRuleMapper;
    @Override
    public List<SmilePointRuleDTO> getPointRuleList(PointRuleSearchParamet searchParamet) {
     return    pointRuleMapper.getPointRuleList(searchParamet);
    }

    @Override
    public SmilePointRuleDTO getPointRuleDTOByType(String ruleType) {
        PointRuleSearchParamet searchParamet=new PointRuleSearchParamet();
        searchParamet.setPointSourceType(ruleType);
        List<SmilePointRuleDTO> pointRuleList = pointRuleMapper.getPointRuleList(searchParamet);
        if (ObjectUtils.isListSole(pointRuleList)) {
           return pointRuleList.get(0);
        }
        return null;
    }
}
